package com.iqiyi.pps.epg.web.webapp.action.auth;

import com.iqiyi.pps.epg.core.model.auth.SysUser;
import com.iqiyi.pps.epg.core.utils.SpringSecurityUtils;
import com.iqiyi.pps.epg.web.webapp.action.BaseAction;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.*;
import org.springframework.context.annotation.Scope;

/**
 * Created by IntelliJ IDEA.
 * User: Dell
 * Date: 11-1-14
 * Time: 下午12:00
 * To change this template use File | Settings | File Templates.
 */

@Namespace("/auth/update")
@Scope("prototype")
//定义名为reload的result重定向到user.action, 其他result则按照convention默认.
@Results( { @Result(name = BaseAction.RELOAD, location = "user.action", type = "redirect") })
public class CurrentUserAction extends ActionSupport {

    private SysUser entity;

    @Actions(@Action(value = "update",results = {@Result(name = SUCCESS, location = "/WEB-INF/content/auth/user/user-update.jsp")}))
    public String updateUser() throws Exception {
      //  prepareModel();
        entity = (SysUser) SpringSecurityUtils.getCurrentUser();
      //  checkedRoleIds = entity.getRoleIds();
      //  id = entity.getId();

        System.out.println("passwd"+entity.getPassword());
        return SUCCESS;
    }

    public SysUser getEntity() {
        return entity;
    }

    public void setEntity(SysUser entity) {
        this.entity = entity;
    }
}
